|
Hi there,
if i got an 3 arraylist to be serialize, each with different type(Point[] or int) how do i deserialize them back to the 3 different arraylist accordingly. Should i save the number of items in each of the arraylist? Check the type? What other methods would u suggest?
Thanks in advance.
|
|
|
|
|
If you serialize the lists into separate streams, just remember which list resides in which stream and you'll be fine. If you serialize the lists into one common stream, though, make sure you deserialize them in the exact same order they were serialized.
|
|
|
|
|
i need to save all the arraylists into a common arraylist and then serialize it because i want to save it into a file. Is this correct?
Below is part of the code i wrote:
In Save()
<br />
ArrayList arr = new ArrayList();<br />
<br />
arr.Add(Arraylist1);
for(int i=0;i<br />
{<br />
GraphicsPathData gpd = new GraphicsPathData((GraphicsPath)PathList[i]);<br />
Stream gpdStream = GraphicsPathData.Serialize(gpd);<br />
arr.Add(gpdStream);<br />
}<br />
<br />
arr.Add(Arraylist1);
<br />
formatter.Serialize(myStream, arr);<br />
myStream.Close();<br />
<br />
in OpenFile()
<br />
ArrayList arr =new ArrayList();<br />
if (openFileDialog.ShowDialog() == DialogResult.OK)<br />
{<br />
filename = openFileDialog.FileName;<br />
Stream myStream = openFileDialog.OpenFile();<br />
if (myStream != null)<br />
{<br />
IFormatter formatter = new BinaryFormatter();<br />
arr = (ArrayList) formatter.Deserialize(myStream);<br />
myStream.Close();<br />
<br />
.................
However the problem here, how can i separate the arr into the correct arraylist?
Thanks for your help
|
|
|
|
|
You don't need a common arraylist to serialize several arraylists into one file. Just make several calls to formatter.Serialize passing the same stream:
formatter.Serialize(myStream, arr1)
formatter.Serialize(myStream, arr2)
formatter.Serialize(myStream, arr3)
To restore the arraylists, make the calls to formatter.Deserialize in the exact same order:
arr1 = (ArrayList) formatter.Deserialize(myStream);
arr2 = (ArrayList) formatter.Deserialize(myStream);
arr3 = (ArrayList) formatter.Deserialize(myStream);
|
|
|
|
|
hi there,
Thanks for the reply. Your solution works perfectly for binary serialization. However, i was wondering, does this concept works the same if i want to use XML serialization?
Thanks.
|
|
|
|
|
Hi i am developing a windows application in C# (in 2003).
My form consists of buttons. I set Flat style to system in properties window.
But no change in the appearance of the button. It is looking normal.
How can i get this(System Style) affect.
Thanks in Advance
Ramu Medida
|
|
|
|
|
Change your Flat Style as "System" it will take your Operating System style/skins (Ex. XP).
|
|
|
|
|
Im extreamly sorry ., i might misled you please walk through the following
[^]
Thanks
|
|
|
|
|
Thank you Very much.
Thanks and Regards
Ramu
|
|
|
|
|
Hi
I did code to access my control(text box etc) inside the thread but when i upgrade it into VS 2005 it is saying "cross thread operation not valid" how can fix it ?
- Thanks
|
|
|
|
|
Dear Siva,
Is that is happening in debugh mode or it happens in release build also?
I also face the same problem while debugging the application but it works fine in release build.
Regards,
Sunil Tonger
|
|
|
|
|
Control.CheckForIllegalCrossThreadCalls = false;
Put this line in the constructor of your form.
|
|
|
|
|
Yes, when you are doing something referred to as "Illigal" then obvious choice is to disable the check so you can get on with your high quality code.
Look at Invoke and BeginInvoke. Yes, they are annoying, but not half as annoying as the deadlocks you get when not using them.
|
|
|
|
|
Control.CheckForIllegalCrossThreadCalls = false; will this cause any issues?
I have code in 2003 which access controls inside thread and so far it is going good. I placed this command in 2005 and tried it already and it looks OK, i want to make sure by making this "CheckForIllegalCrossThreadCalls" as false will not cause any serious issues. Do you think?
http://www.codeproject.com/csharp/threadsafeforms.asp[^] this should be the right choice but lot of rework
|
|
|
|
|
Of course setting the option to false will cause issues. Microsoft did not add a random unneeded check just for the fun of it.
Typical behaviour will be random hanging your entire GUI. This can happen on all systems, or just a few. It can also appear to be working fine, then suddently start hanging due to an update from Microsoft, a new OS, or whatever.
|
|
|
|
|
just use delegate for invoking them
Here is my code and it's work fine in vs2005
public delegate void CrossThreadHandle(object arg);
void SetLabelStatus(object txt)
{
this.labelDownloadStatus.Text=txt as string;
}
void dl_StatusChanged(Downloader sender, Downloader.DownloadStatus status)
{
CrossThreadHandle dLabel=new CrossThreadHandle(this.SetLabelStatus);
this.Invoke(dLabel,sender.Status.ToString());
Application.DoEvents();
}
Hope it would Help
|
|
|
|
|
|
can i make the setup to detect the .net framework automatically, before the setup of the application take place.so that i don't get the message .net framework is not installed in the machine.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Hi Sonia,
Assuming that you are using .net Setup & Deployment project in VS.
Create a Launch Condition - Add Registry Search - set the RegKey & Value property to:
Keys:
For the .NET Framework 1.0:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.0
For the .NET Framework 1.1:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.1
For the .NET Framework 2.0:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v2.0
Value:
For the .NET Framework 1.0: "3705"
For the .NET Framework 1.1: "4322"
For the .NET Framework 2.0: "50727"
Then add new LauchCondition and set the Condition property to:
For the .NET Framework 1.0:
REGISTRYVALUE = "3321-3705"
For the .NET Framework 1.1:
REGISTRYVALUE="3706-4322"
For the .NET Framework 2.0:
REGISTRYVALUE="50727-50727"
Hope that helps.
Regards,
Bhupi Bhai.
|
|
|
|
|
what is new launch condition and Condition property ?
Please explain
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
If you are working in VS - 2005 then you should be able to see a Button called Prerequisites on your Setup Project Property. Hit that button and gothrough.
Thanks
|
|
|
|
|
i have gone through that
i selected the second option there, choose the location where the application is residing
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Insted you can select First Option know? It will download from Internet automatically when you deploy into customer place? If you select second option then .Net 2.0 Framework should go along with your application.
Choose which ever you want? And is it help out to you or no?
Thanks
|
|
|
|
|
will u please explain me the steps if i select the option 2
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|